package com.thymeleaf.demo.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.thymeleaf.demo.util.Common;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

@Component
public class MyMetaObjectHandle implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("updatetime", Common.getCurrent(), metaObject);
        this.setFieldValByName("createtime", Common.getCurrent(), metaObject);
    }

    private void setFieldValByName(String updatetime, int current, MetaObject metaObject) {
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updatetime", Common.getCurrent(), metaObject);
    }
}
